package com.operate.api.app.search.controller;

import com.github.pagehelper.PageInfo;
import com.operate.api.app.info.domain.vo.AppBannerSearchVO;
import com.operate.api.app.info.domain.vo.AppBannerVO;
import com.operate.api.app.info.domain.vo.AppCompanySearchVO;
import com.operate.api.app.info.domain.vo.AppCompanyVO;
import com.operate.api.app.info.service.IAppCompanyService;
import com.operate.api.app.search.domain.vo.AppDramaSearchVO;
import com.operate.api.app.search.domain.vo.AppDramaVO;
import com.operate.api.base.ApiIndex;
import com.operate.api.base.IDEntity;
import com.operate.api.base.R;
import com.operate.api.base.RestPage;
import com.operate.api.operate.banner.service.IBannerService;
import com.operate.api.operate.dramas.service.IDramasService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api( tags = ApiIndex.AppSearchController)
@RequestMapping(value = "/api/app/search")
@RestController
public class AppSearchController {


    @Autowired
    private IAppCompanyService companyService;
    @Autowired
    private IDramasService dramasService;

    @ApiOperation(value = "查询制作方")
    @GetMapping(value = "/company_list")
    public R<RestPage<List<AppCompanyVO>>> company_list(
            @ApiParam(value = "查询参数") @ModelAttribute AppCompanySearchVO searchVO) {
        List<AppCompanyVO> list = companyService.getInfoList(searchVO);
        RestPage restPage = new RestPage(new PageInfo(list), list);
        return new R(restPage);
    }

    @ApiOperation(value = "根据制作方ID查询制作方信息")
    @GetMapping(value = "/company_one")
    public R<AppCompanyVO> company_one(
            @ApiParam(value = "查询参数") @ModelAttribute IDEntity id) {
        AppCompanyVO one = companyService.getCompanyOne(id);
        return new R(one);
    }

    @ApiOperation(value = "查询剧目")
    @GetMapping(value = "/drama_list")
    public R<RestPage<List<AppDramaVO>>> drama_list(
            @ApiParam(value = "查询参数") @ModelAttribute AppDramaSearchVO searchVO) {
        List<AppDramaVO> list = dramasService.getAppDramaList(searchVO);
        RestPage restPage = new RestPage(new PageInfo(list), list);
        return new R(restPage);
    }


}